import React from 'react';
import { Select, Form } from 'antd';

interface ModelField {
  name: string;
  label: string;
  type: string;
  required?: boolean;
}

interface ModelFieldSelectorProps {
  modelName: string;  // 保留这个属性以保持接口一致性
  fields: ModelField[];
}

const ModelFieldSelector: React.FC<ModelFieldSelectorProps> = ({ fields }) => {
  if (!fields || fields.length === 0) {
    return <div>该模型没有可用字段</div>;
  }

  return (
    <div>
      {fields.map((field) => (
        <Form.Item 
          key={field.name} 
          label={field.label || field.name}
          name={['dataBinding', 'fields', field.name]}
        >
          <Select placeholder={`选择要映射到 ${field.label || field.name} 的属性`}>
            {/* 这里可以根据组件类型添加可用的映射选项 */}
            <Select.Option value={field.name}>{field.label || field.name}</Select.Option>
          </Select>
        </Form.Item>
      ))}
    </div>
  );
};

export default ModelFieldSelector; 